package homeworkIOC;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component("fws")
public class FileWriterService {
	@Value("${setPath}")
	private String classpath ;
	@Value("${setText}")
	private String text;
	
	public String getContent(){ return text; }
	
	public void write(String content){
		PrintWriter out;
		try {
			out = new PrintWriter(
					new BufferedWriter(
							new OutputStreamWriter(
									new FileOutputStream(classpath))));
			out.println(content);
			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}		
	}
}
